﻿using Eneta.Portal.Forum.Core.Domain.Entities;
using Eneta.Portal.Forum.Core.Service.Application;
using Microsoft.SharePoint;

namespace Eneta.Portal.Forum.Core.Service.Builders
{
    public class TopicListBuilder : ListBuilder
    {
        // Methods
        public TopicListBuilder()
        {
            listName = "spforums_topics";
        }

        public override void AddFields()
        {
            base.AddFieldToList("ForumID", (SPFieldType)9, true);
            base.AddFieldToList("Views", (SPFieldType)9, false);
            base.AddFieldToList("NumPosts", (SPFieldType)9, false);
            base.AddFieldToList("TopicStarterID", (SPFieldType)9, false);
        }

        public override void AddSampleData()
        {
            var topic = new Topic(1, "Welcome to your new SharePoint Forum");
            topic.TopicStarterId = 1;
            RepositoryRegistry.TopicRepository.Save(topic);
        }
    }
}
